package com.blood.modules.pregnancy.controller;

import com.blood.core.annotation.Idempotent;
import com.blood.core.resp.PageResult;
import com.blood.core.resp.ResponseResult;
import com.blood.modules.pregnancy.dto.req.PregnancyAbnormalGatherInfoReq;
import com.blood.modules.pregnancy.dto.req.PregnancyGatherInfoPageReq;
import com.blood.modules.pregnancy.dto.req.PregnancyGatherInfoReq;
import com.blood.modules.pregnancy.dto.req.PregnancyGatherInfoSaveReq;
import com.blood.modules.pregnancy.dto.req.PregnancyGatherOverSaveReq;
import com.blood.modules.pregnancy.dto.resp.*;
import com.blood.modules.pregnancy.service.IPregnancyGatherInfoService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 孕妇信息采集Controller
 *
 * @author daoren
 * @date 2022-11-25 09:00:10
 */
@Api(value = "孕妇信息采集", tags = "孕妇信息采集")
@ApiSort(904)
@RestController
@RequestMapping("/pregnancy/gather")
public class PregnancyGatherInfoController {

    /**
     * 孕妇信息采集服务.
     */
    @Autowired
    private IPregnancyGatherInfoService pregnancyGatherInfoService;

    /**
     * 采集信息分页查询
     *
     * @param req
     * @return 分页数据
     */
    @PostMapping("/gatherPageList")
    @ApiOperation(value = "采集信息分页查询")
    public ResponseResult<PageResult<PregnancyGatherListResp>> gatherPageList(@RequestBody PregnancyGatherInfoPageReq req) {
        return pregnancyGatherInfoService.gatherPageList(req);
    }

    /**
     * 历史异常分页查询
     *
     * @param req
     * @return 分页数据
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "历史异常分页查询")
    public ResponseResult<PageResult<PregnancyGatherInfoPageResp>> pageList(@RequestBody PregnancyGatherInfoPageReq req) {
        return pregnancyGatherInfoService.pageList(req);
    }

    /**
     * 信息录入.
     *
     * @param req 保存参数
     * @return 添加结果
     */
    @ApiOperation(value = "信息录入")
    @PostMapping(value = "/add")
    @Idempotent
    public ResponseResult<PregnancyGatherSaveResp> add(@RequestBody @Validated PregnancyGatherInfoSaveReq req) {
        return pregnancyGatherInfoService.saveInfo(req);
    }


    /**
     * 撤销采集信息.
     *
     * @param gatherId 采集信息Id
     * @return 结果
     */
    @ApiOperation(value = "撤销采集信息")
    @GetMapping(value = "/revocation")
    public ResponseResult<Void> revocation(@ApiParam(value = "采集信息Id", type = "String") @RequestParam("gatherId") String gatherId) {
        return pregnancyGatherInfoService.revocation(gatherId);
    }

    /**
     * 查询异常信息.
     *
     * @param gatherId 采集id
     * @return 异常信息
     */
    @ApiOperation(value = "查询异常信息")
    @GetMapping(value = "/queryAbnormal")
    public ResponseResult<PregnancyGatherResp> queryAbnormal(@ApiParam(value = "异常信息Id", type = "String") @RequestParam("gatherId") String gatherId) {
        return pregnancyGatherInfoService.getAbnormalInfo(gatherId);
    }

    /**
     * 处理录入异常信息.
     *
     * @param req 保存参数
     * @return 添加结果
     */
    @ApiOperation(value = "处理录入异常信息")
    @PostMapping(value = "/delAdd")
    @Idempotent
    public ResponseResult<Void> delAdd(@RequestBody @Validated PregnancyAbnormalGatherInfoReq req) {
        return pregnancyGatherInfoService.delAdd(req);
    }

    /**
     * 完结信息录入.
     *
     * @param req 修改参数
     * @return 修改结果
     */
    @ApiOperation(value = "完结信息录入")
    @PostMapping(value = "/overAdd")
    @Idempotent
    public ResponseResult<Void> overAdd(@RequestBody @Validated PregnancyGatherOverSaveReq req) {
        return pregnancyGatherInfoService.overAdd(req);
    }

    /**
     * 获取采集信息页面数据.
     *
     * @param req 请求参数
     * @return 列表信息
     */
    @ApiOperation(value = "获取采集信息页面数据")
    @PostMapping(value = "/getInfo")
    public ResponseResult<PregnancyGatherInfoResp> getInfo(@RequestBody PregnancyGatherInfoReq req) {
        return pregnancyGatherInfoService.getInfo(req);
    }

    /**
     * 列表详情查询
     *
     * @param id
     * @return 详情
     */
    @GetMapping("/findDetailById")
    @ApiOperation(value = "列表详情查询")
    public ResponseResult<PregnancyGatherDetailInfoResp> findDetailById(@ApiParam(value = "孕妇id", type = "String") @RequestParam("id") String id) {
        return pregnancyGatherInfoService.findDetailById(id);
    }
}
